package com.liu.socket;

import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;

public class SocketTcpClient {
    public static void main(String[] args) throws IOException {
        //链接服务器
        Socket socket = new Socket(InetAddress.getLocalHost(), 9999);
        System.out.println("链接成功");
        System.out.println(socket.getClass());
        //得到和socket关联的输出流对象
        OutputStream outputStream = socket.getOutputStream();
        outputStream.write("hello,world".getBytes());
        //关闭流和socket
        outputStream.close();
        socket.close();

        System.out.println("客户端退出");
    }
}
